home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 129_01 / 210misc.c < prev    next >
Text File  |  1985-03-09  |  11KB  |  367 lines

  1. /************************************************************************/
  2. /*                misc.c                    */
  3. /*                                    */
  4. /*    Random functions...                        */
  5. /************************************************************************/
  6.  
  7. /************************************************************************/
  8. /*                history                 */
  9. /*                                    */
  10. /* 84Dec18 JLS    transmitFile() fixed so mAbort() affects <.rb> cmd.    */
  11. /* 84Dec17 JLS    Tutorial() fixed so on mabort() is stops instantly.    */
  12. /* 84Dec16 HAW    Tutorial() fixed so it can't access non-existent drives.*/
  13. /* 84Dec16 HAW&JLS download() & transmitFile() modified for new WC.    */
  14. /* 84Jul08 HAW    file_RO changed to detect R/O drives.            */
  15. /* 84Jul03 HAW    file_RO written to check .SYS files for R/O status.    */
  16. /* 84Jun23 HAW & JLS  patchDebug put under control of conditional comp. */
  17. /* 84Jun16 JLS & HAW  Configure fixed so that ".Enter Con..." works    */
  18. /* 84Jun10 JLS    Function changedate() installed.            */
  19. /* 84May01 HAW    Starting 1.50a upgrade.                 */
  20. /* 83Mar12 CrT    from msg.c                        */
  21. /* 83Mar03 CrT & SB   Various bug fixes...                */
  22. /* 83Feb27 CrT    Save private mail for sender as well as recipient.    */
  23. /* 83Feb23    Various.  transmitFile() won't drop first char on WC... */
  24. /* 82Dec06 CrT    2.00 release.                        */
  25. /* 82Nov05 CrT    Stream retrieval.  Handles messages longer than MAXTEXT.*/
  26. /* 82Nov04 CrT    Revised disk format implemented.            */
  27. /* 82Nov03 CrT    Individual history begun.  General cleanup.        */
  28. /************************************************************************/
  29.  
  30. #include <210ctdl.h>
  31.  
  32. /************************************************************************/
  33. /*                contents                */
  34. /*                                    */
  35. /*    changeDate()        allow changing of date            */
  36. /*    configure()        sets terminal parameters via dialogue    */
  37. /*    doCR()            newline on modem and console        */
  38. /*    download()        menu-level routine for WC-protocol sends*/
  39. /*    file_RO()        checks for file and drive being R/O    */
  40. /*    patchDebug()        display/patch byte            */
  41. /*    printDate()        prints out date             */
  42. /*    putFlChar()        readFile() -> disk file interface    */
  43. /*    putWCChar()        filter[]s, readFile() to putMsgChar()    */
  44. /*    transmitFile()        send a host file, no formatting     */
  45. /*    tutorial()        prints a .hlp file            */
  46. /*    upload()        menu-level read-via-WC-protocol fn    */
  47. /*    visible()        convert control chars to letters    */
  48. /************************************************************************/
  49.  
  50. /************************************************************************/
  51. /*    changedate() gets the date from the aide and remembers it    */
  52. /************************************************************************/
  53. changeDate()
  54. {
  55.     mPrintf("Current date is: ");
  56.     printdate();
  57.     if (!getYesNo("Enter a new date"))
  58.     return ;
  59.     interpret(pInitDate);
  60. }
  61.  
  62. /************************************************************************/
  63. /*    configure() sets up terminal width etc via dialogue        */
  64. /************************************************************************/
  65. configure() {
  66.     termWidth    = getNumber(" Screen width",          10, 255);
  67.     termNulls    = getNumber(" #Nulls",               0, 255);
  68.     termUpper    = getYesNo(" Uppercase only"             )    ?  UCMASK  :  0;
  69.     termLF    = getYesNo(" Linefeeds"              )    ?  LFMASK  :  0;
  70. /*  termTab    = getYesNo(" Tabs"                 )    ?  TABMASK :  0;
  71. */  expert    =!getYesNo(" Helpful hints"             )    ?  EXPERT  :  0;
  72.  
  73.     /* Now make it (only) semi-permanent     --JLS&HAW */
  74.     logBuf.lbwidth = termWidth;
  75.     logBuf.lbnulls = termNulls;
  76.     logBuf.lbflags = expert | termUpper | termLF | termTab | aide;
  77. }
  78.  
  79. /************************************************************************/
  80. /*    doCR() does a newline on modem and console            */
  81. /************************************************************************/
  82. doCR() {
  83.     int i;
  84.  
  85.     crtColumn    = 1;
  86.     if (outFlag) return;    /* output is being s(kip)ped    */
  87.  
  88.     putChar(NEWLINE);
  89.     if (haveCarrier) {
  90.     if (!usingWCprotocol) {
  91.         outmod('\r');
  92.         for (i=termNulls;  i;  i--) outmod(0);
  93.         if (termLF) outmod('\n');
  94.     } else {
  95.         sendWCChar('\r');
  96.         if (termLF) sendWCChar('\n');
  97.     }
  98.     }
  99. #ifdef XYZZY
  100. /* test code only */
  101.     else {
  102.     if (usingWCprotocol) {
  103.         sendWCChar('\r');
  104.         if (termLF) sendWCChar('\n');
  105.     }
  106.     }
  107. #endif
  108.     prevChar    = ' ';
  109. }
  110.  
  111. /************************************************************************/
  112. /*    download() is the menu-level send-message-via-WC-protocol fn    */
  113. /************************************************************************/
  114. download(whichMess, revOrder)
  115. char whichMess, revOrder;
  116. {
  117.     outFlag    = OUTOK;
  118.     if (!expert)   tutorial("wcdown.blb");
  119.  
  120.     outFlag    = OUTOK;
  121.     if (!getYesNo("Ready"))  return;
  122.  
  123.     /* here we go: */
  124.     echo        = NEITHER;
  125.     usingWCprotocol    = TRUE     ;    /* all points bulletin        */
  126.  
  127.     if (doWC(STARTUP))    {    /* Caller wasn't ready, so don't try    */
  128.  
  129.     showMessages(whichMess, revOrder);
  130.  
  131.     doWC(FINISH);            /* Clean up after the WC downloader     */
  132.     }
  133.  
  134.     setUp(FALSE);
  135.     usingWCprotocol    = FALSE  ;
  136. }
  137.  
  138. /************************************************************************/
  139. /*    file_RO() checks the given file for R/O status    --HAW        */
  140. /************************************************************************/
  141. file_RO(fd)
  142. int fd;
  143. {
  144. #define R_O_MASK    128
  145.     char *fc, *fcbaddr(), drive;
  146.     int  vector, bdos();
  147.  
  148.     if ((fc = fcbaddr(fd)) == ERROR)
  149.         return TRUE;        /* No such file, return  TRUE */
  150.     if ((fc[9] & R_O_MASK) != 0)
  151.         return TRUE;        /* Bit set, file is R/O */
  152.     /* else */
  153.     if ((drive = fc[0]) == 0)    /* Then get default disk from BDOS */
  154.         drive = bdos(25) + 1;
  155.                     /* Wheee!  Bit operations. */
  156.     vector = (bdos(29) << (16 - drive)) & 0x8000;
  157.     return vector;
  158. }
  159.  
  160. #ifdef XYZZY
  161. /************************************************************************/
  162. /*    patchDebug()                            */
  163. /************************************************************************/
  164. patchDebug() {
  165.     unsigned  i, j, page;
  166.     char      finished, *pc;
  167.  
  168.     mPrintf("\bpatch\n ");
  169.     page = getNumber("page", 0, 255);
  170.     finished = FALSE;
  171.     do {
  172.     for (i=16, pc= (page*256);  i;    i--)   {
  173.         mPrintf("%d ", pc);
  174.         for (j=16;    j;  j--)   {
  175.         mPrintf("%c", visible(*pc++));
  176.         }
  177.         mPrintf("\n ");
  178.     }
  179.     switch (toLower(iChar()))   {
  180.     case 'r':
  181.         pc    = getNumber("adr", 0, 65355);
  182.         *pc = getNumber("val", 0, 255);
  183.         break;
  184.     case 'n':    page++;         break;
  185.     case 'p':    page--;         break;
  186.     default:    finished = TRUE;    break;
  187.     }
  188.     } while (!finished);
  189. }
  190. #endif
  191. /************************************************************************/
  192. /*    printDate() prints out current date.                */
  193. /************************************************************************/
  194. printDate()
  195. {
  196.     mPrintf("%d%s%02d ", interpret(pGetYear),
  197.              monthTab[interpret(pGetMonth)],
  198.              interpret(pGetDay));
  199. }
  200.  
  201. /************************************************************************/
  202. /*    putFlChar() is used to upload files                */
  203. /*    returns: ERROR on problems else TRUE                */
  204. /*    Globals: msgBuf.mbtext is used as a buffer, to save space    */
  205. /************************************************************************/
  206. putFlChar(c)
  207. char c;
  208. {
  209.     return  putC(c, msgBuf.mbtext) != ERROR;
  210. }
  211.  
  212. /************************************************************************/
  213. /*    putWCChar() filter[]s from readFile() to putMsgChar()        */
  214. /*    Returns: ERROR if problems, else TRUE                */
  215. /*    Globals: outFlag is set to OUTSKIP when an ascii EOF (^Z) is    */
  216. /*        encountered, and no further text is written to disk.    */
  217. /************************************************************************/
  218. int putWCChar(c)
  219. int c;
  220. {
  221.     if (outFlag)    return TRUE;    /* past ascii EOF.  ignore.    */
  222.  
  223.     if (c == ERROR) {
  224.     /* EOF.  Note for overkill:    */
  225.     outFlag = OUTSKIP;
  226.     return TRUE;
  227.     }
  228.  
  229.     c    &= 0x7F;    /* cut high stuff off    */
  230.  
  231.     if (c == CPMEOF) {
  232.     /* ascii EOF.  Ignore rest of file:    */
  233.     outFlag = OUTSKIP;
  234.     return TRUE;
  235.     }
  236.  
  237.     return  putMsgChar(filter[c]);
  238. }
  239.  
  240. /************************************************************************/
  241. /*    transmitFile() dumps a host file with no formatting        */
  242. /***********